﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication3
{
    /// <summary>
    /// Contains methods for global activity
    /// </summary>
    class Utils
    {
        /// <summary>
        /// This methods changes the caption of datagridview, as by
        /// default it dont honour the caption propery of datatable
        /// Problem listed here:
        /// http://geekswithblogs.net/glozano/archive/2006/10/09/93572.aspx
        /// </summary>
        /// <param name="gview">Grid to be modified</param>
        public static void UpdaateMappingColumnName(System.Windows.Forms.DataGridView gview )
        {
            System.Data.DataTable dt = gview.DataSource as System.Data.DataTable;
            if (dt != null)
            {
                for (int i = 0; i < gview.Columns.Count; i++)
                {
                    gview.Columns[i].HeaderText = dt.Columns[i].Caption;
                }
            }
        }

    }
}
